<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <?php
        include_once('../includes/utilidades.php');
session_start();
//print_r($tablas);
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.

CREATE OR REPLACE VIEW vatletatemporadaclub AS
SELECT at.id as idatleta, at.nombre AS Nombre, at.apellido1 AS Apellido1, at.Apellido2 AS Apellido2, at.fechanacimiento AS FechaNacimiento, gen.nombre AS Genero, cl.id AS idclub, cl.nombre AS Club, te.id AS idtemporada, te.nombre AS Temporada, cat.id AS idcategoria, cat.nombre AS Categoria
FROM atleta at, temporada te, club cl, ratletatemporadaclub rel, genero gen, categoria cat
WHERE rel.idatleta = at.id
AND rel.idclub = cl.id
AND at.idgenero = gen.id
AND rel.idcategoria = cat.id
AND rel.idtemporada = te.id


 */

//conectaDb();
$clubid = $_REQUEST['idcluborigen'];
$atletaid= $_REQUEST['idatleta'];
//$club = select("select * from club", "id=" . $clubid);
$temporada = $_SESSION['temporada'];

$clubes = select2('select * from club order by nombre');
$atleta = select2('select * from vatletatemporadaclub where idatleta=' . $atletaid);


print_r($temporada);
//print_r($_SESSION);
//print_r($clubes);
//print_r($atleta);

$select = getSelectHTML('vclub', 'id', 'nombre', 'idclub', $clubid, array(0,"-"));

print "<h1> Cambio de Club de "  . $atleta[0]['Nombre'] . " " . $atleta[0]['Apellido1'] . " " . $atleta[0]['Apellido2'] . " (" . $atleta[0]['Categoria'] . ")" . "</h1>";
print "<form name='nuevoclub' action='doCambiarClub.php' method='post'>";
print "<table>";
print "<tr><td>Club actual:</td><td>" .$atleta[0]['Club'] . "</td></tr>";
 print "<tr><td>Nuevo club:</td><td>" . $select . "</td>";
 print "<input type=hidden name=temporada value='" .  $temporada[0]['id'] . "'/>";
 print "<input type=hidden name=idatleta value='" . $atletaid . "'/>";
 print "<tr><td><input type='submit' value='Aceptar'/></td></tr>";
 print "</table>";
//print $atleta[0]['Nombre'] . " " . $atleta[0]['Apellido1'] . " " . $atleta[0]['Apellido2'] . " (" . $atleta[0]['Categoria'] . ")";

print "</form>";


        ?>
    </body>
</html>
